<%@page import="com.tomasio.projects.organization.webservices.TelefoneDTO"%>
<%@page import="com.tomasio.projects.organization.webservices.EmailDTO"%>
<%@page import="javax.servlet.jsp.tagext.TryCatchFinally"%>
<%@page import="java.util.List"%>
<%@page import="com.tomasio.projects.organization.webservices.MatriculaDTO"%>
<%@page import="com.tomasio.projects.organization.webservices.EfetivoWSProxy"%>
<%@page import="com.tomasio.projects.organization.webservices.EfetivoWS"%>
<%
/**
 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */
%>

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<portlet:defineObjects />
<style>
#list td {
 border-bottom: 1px solid #ccc;
}
</style>


<portlet:renderURL var="filterURL">
    <portlet:param name="jspPage" value="/view.jsp" />
</portlet:renderURL>

<aui:form action="<%= filterURL %>" method="post">
<table>
	<tr>
		<td><aui:input label="" name="term" type="text" /></td>
		<td><aui:button type="submit" value="Buscar"/></td>
	</tr>

</table>
    
    
</aui:form>

<br/>
<table width="100%" id="list">

<%
	EfetivoWS proxy = new EfetivoWSProxy();
    String term = renderRequest.getParameter("term");
    if(term == null)
    	term = "";
    MatriculaDTO []  matriculas = null;
    matriculas = proxy.searchMatriculaByName(term);
    if(matriculas == null){
    	matriculas = new MatriculaDTO[0];
    }

    for(int i=0; i < matriculas.length; i++){
    	MatriculaDTO matricula = matriculas[i];
     	if(matricula.getPessoa().getEmails() != null 
     			&& matricula.getPessoa().getTelefones() != null
     			&& matricula.getPessoa().getEmails().length > 0
     			&& matricula.getPessoa().getTelefones().length > 0 ){
%>



	<tr>
		<td>
		<%= matricula.getCargo() %>&nbsp;<%= matricula.getPessoa().getNome() %>
		</td>
		<td>
			
			<%
				if(matricula.getPessoa().getEmails() != null){
					for(int j=0; j < matricula.getPessoa().getEmails().length; j++){
						EmailDTO email = matricula.getPessoa().getEmails()[j];
						if(email.getAddress().contains("@pame.intraer")){
			%>
							<%= email.getAddress() %><br/>
			<%		
						}
					}
				}
					
			%>
		</td>
		<td>
			
			<%
				if(matricula.getPessoa().getTelefones() != null){
					for(int j=0; j < matricula.getPessoa().getTelefones().length; j++){
						TelefoneDTO telefone = matricula.getPessoa().getTelefones()[j];
						if(telefone.getNumero().contains("2117")){
			%>
							<%= telefone.getNumero() %><br/>
			<%		
						}
					}
				}
					
			%>
		</td>
	</tr>
<%
    	}
    }
%>
  
</table>
